<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">

                <div class="box">
                    <div class="box-header">

                        <div class="row">
                            <div class="col-sm-2">
                                <select class="form-control" id="input_object">
                                    <option value="-1">--全部类型--</option>
                                    <option value="1">电影</option>
                                    <option value="2">电视剧</option>
                                    <option value="3">综艺</option>
                                    <option value="4">动漫</option>
                                </select>
                            </div>

                            <div class="col-sm-2">
                                <select class="form-control" id="input_state">
                                    <option value="-1">--状态--</option>
                                    <option value="0">正常</option>
                                    <option value="1">删除</option>

                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="form-control"
                                        id="input_report">
                                    <option value="-1">--举报--</option>
                                    <option value="0">未举报</option>
                                    <option value="1">举报的</option>
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="form-control"
                                        id="input_parent">
                                    <option value="-1">--父子级显示--</option>
                                    <option value="0">只显示父级</option>
                                    <option value="1">只显示子级</option>
                                </select>
                            </div>

                            <div class="col-sm-1 pull-right">
                                <button class="btn btn-block btn-default " id ="btn_search" onclick="searchCommentList()">查询
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-bordered table-striped dataTable">
                            <tbody>
                            <thead>
                            <tr>
                                <th>类型</th>
                                <th>昵称</th>
                                <th>评论内容</th>
                                <th>举报次数</th>
                                <th>状态</th>
                                <th>是否子回复</th>
                                <th>评论时间</th>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>
                            <tbody id="bodycontent">


                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                    <div id="pagecontent" class="pagination"></div>
                </div><!-- /.box -->
            </div>
        </div>
    </section>

</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <!--layoutmain footer...-->
    <!--<br />-->
    <script type="text/javascript">
        var comment_data ={};
        function  searchCommentList() {
            comment_data = {
                classtype:$('#input_object').val(),
                objectid:'',
                commentid:'',
                tocommentid:'',
                parentid:$('#input_parent').val(),
                reportct:$('#input_report').val(),
                show:$('#input_state').val(),
                pno: 1,
                pagesize: 10,
                allcount:-1
            };
            LoadfilmCommentList();

        }

        searchCommentList();
        function LoadfilmCommentList() {
            $('#pagecontent').html('');
            $.ajax({
                    url: '/api/comment/commentlist',
                    data: comment_data,
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {
                                comment_data.allcount = data.result.count;
                                var html = '';
                                $.each(data.result.list, function (index, item) {
                                    html += getHtml(item);
                                })
                                $('#bodycontent').html(html);
                                ShowPage('pagecontent', comment_data, function (pno) {
                                    comment_data.pno = pno;
                                    LoadfilmCommentList();
                                });
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
        function  getHtml(dataObject) {
            var stateHtml='';
            if (dataObject.fShow==0){

                stateHtml= '<span class="label label-success">正常</span>'
            }
            else if (dataObject.fShow=='1'){
                stateHtml= '<span class="label label-danger">删除</span>'
            }
            var classTypeHtml="";
            classTypeHtml=GetClassTypeName(dataObject.fClasstype);
            return ' <tr>'+
                '<td>'+classTypeHtml+'</td>'+
                '<td>'+dataObject.fCommentnick+'</td>'+
                '<td>'+dataObject.fContent+'</td>'+
                '<td>'+dataObject.fReportct+'</td>'+
                '<td>'+stateHtml+'</td>'+
                '<td>'+dataObject.fParentid+'</td>'+
                '<td>'+dataObject.fIntime+'</td>'+
                '<td>' +
                '<a style="cursor: pointer" href="#" onclick="UpdateCommentState(\''+dataObject.fId+'\',1,'+dataObject.fParentid+')">删除</a>&nbsp;&nbsp;' +
                '<a style="cursor: pointer" href="#" onclick="UpdateCommentState(\''+dataObject.fId+'\',0,'+dataObject.fParentid+')">显示</a></td>'+
                '</tr>';
        }
        function UpdateCommentState(fid,state,parentid) {
            $.ajax({
                    url: '/api/comment/updatecommentstate',
                    data: {fid: fid,state:state,parentid:parentid},
                    type: 'POST',
                    contentType: "application/x-www-form-urlencoded",
                    dataType: 'json',
                    success: function (data) {
                        if (data) {
                            if (data.code=='OperateOk'){
                                dialog({
                                    title:'提示',
                                    content: '操作成功！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                                LoadfilmCommentList();
                            }
                            else{
                                dialog({
                                    title:'提示',
                                    content: '操作失败！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>